log using S11_S18_balance.smcl,replace
use  NER_panel_data.dta, clear
gen country=1
append using NIGERIA_panel_data.dta
replace country=2 if country ==.

append using ETHIOPIA_panel_data.dta
replace country=3 if country ==.

append using UGA_panel_data.dta
replace country=4 if country ==.

append using TZA_panel_data.dta
replace country=5 if country ==.

append using MWI_panel_data.dta
replace country=6 if country ==.

xtset HHID_panel year

label define country 1 "Niger" 2 "Nigeria" 3 "Ethiopia" 4 "Uganda" 5 "Tanzania" 6 "Malawi"
label values country country

gen dyear=1
egen total_year=sum(dyear), by(HHID_panel)



gen balance=0
replace balance=1 if total_year==2&country==1
replace balance=1 if total_year==4&country==2
replace balance=1 if total_year==3&country==3
replace balance=1 if total_year==7&country==4
replace balance=1 if total_year==5&country==5
replace balance=1 if total_year==4&country==6
tab country year

keep if balance==1


foreach x of varlist hhsize dependent_share head_age female_head head_read  motobike phone  electricity wagejob enterprise weather_shock  plot_area other_crop hdd9 pdd9 no_species{
egen `x'_mean=mean(`x'), by(HHID_panel)
}



tab year, generate(year_)
global year_NIGER year_4
global year_NIGERIA year_3 year_5 year_8
global year_ETHIOPIA year_6
global year_UGANDA   year_3 year_4 year_6 year_8 year_10
global year_TANZANIA year_1 year_5 year_7
global year_MALAWI year_3 year_6 
global xlist hhsize dependent_share head_age female_head head_read  motobike phone  electricity wagejob enterprise weather_shock  plot_area other_crop  motobike_mean phone_mean electricity_mean wagejob_mean enterprise_mean







********************************************************************************
*                                   S11                                        *
********************************************************************************
eststo clear
xtreg hdd9  no_species   $xlist  no_species_mean i.country i.year  , cluster(HHID_panel) 
eststo est1


xtreg hdd9  no_species   $xlist  no_species_mean $year_ETHIOPIA if country==3, cluster(HHID_panel) 
eststo est2

xtreg hdd9  no_species   $xlist  no_species_mean $year_MALAWI if country==6, cluster(HHID_panel) 
eststo est3


xtreg hdd9  no_species   $xlist  no_species_mean $year_NIGER if country==1, cluster(HHID_panel) 
eststo est4


xtreg hdd9  no_species   $xlist  no_species_mean $year_NIGERIA if country==2, cluster(HHID_panel) 
eststo est5


xtreg hdd9  no_species   $xlist  no_species_mean $year_TANZANIA if country==5, cluster(HHID_panel) 
eststo est6

xtreg hdd9  no_species   $xlist  no_species_mean  $year_UGANDA if country==4, cluster(HHID_panel) 
eststo est7

esttab using  S11_balance.rtf, se replace star(* 0.1 ** 0.05 *** 0.01) cells (b(star fmt(%9.3f)) se (par(( )) fmt(%9.3f)))  stats(N r2_b  r2_w r2_o p, fmt(%4.0f %4.3f %4.3f %6.3f)) keep(no_species   $xlist  no_species_mean _cons)






********************************************************************************
*                                   S12                                        *
********************************************************************************
eststo clear

xtreg hdd9  pdd9   $xlist   pdd9_mean i.country i.year, cluster(HHID_panel) 
eststo est1


xtreg hdd9  pdd9   $xlist  pdd9_mean $year_ETHIOPIA if country==3, cluster(HHID_panel) 
eststo est2

xtreg hdd9  pdd9   $xlist  pdd9_mean $year_MALAWI if country==6, cluster(HHID_panel) 
eststo est3


xtreg hdd9  pdd9   $xlist  pdd9_mean $year_NIGER if country==1, cluster(HHID_panel) 
eststo est4


xtreg hdd9  pdd9   $xlist  pdd9_mean $year_NIGERIA if country==2, cluster(HHID_panel) 
eststo est5


xtreg hdd9  pdd9   $xlist  pdd9_mean $year_TANZANIA if country==5, cluster(HHID_panel) 
eststo est6

xtreg hdd9  pdd9   $xlist  pdd9_mean  $year_UGANDA if country==4, cluster(HHID_panel) 
eststo est7
esttab using  S12_balance.rtf, se replace star(* 0.1 ** 0.05 *** 0.01) cells (b(star fmt(%9.3f)) se (par(( )) fmt(%9.3f)))  stats(N r2_b  r2_w r2_o p, fmt(%4.0f %4.3f %4.3f %6.3f)) keep(pdd9   $xlist  pdd9_mean _cons)











******************************************************************************** 
*                                  S13_S14                                     *
********************************************************************************
preserve
eststo clear
drop if hdd9_own==.|hdd9_purchase==.
drop  pdd9_mean no_species_mean hhsize_mean dependent_share_mean head_age_mean female_head_mean head_read_mean motobike_mean phone_mean electricity_mean wagejob_mean enterprise_mean weather_shock_mean plot_area_mean other_crop_mean
foreach x of varlist pdd9 hhsize dependent_share head_age female_head head_read  motobike phone  electricity wagejob enterprise weather_shock  plot_area other_crop{
egen `x'_mean=mean(`x'), by(HHID_panel)
}

eststo clear
xtreg hdd9_own  pdd9   $xlist  pdd9_mean i.country i.year  , cluster(HHID_panel) 
eststo est1


xtreg hdd9_own  pdd9   $xlist  pdd9_mean $year_ETHIOPIA if country==3, cluster(HHID_panel) 
eststo est2

xtreg hdd9_own  pdd9   $xlist  pdd9_mean $year_MALAWI if country==6, cluster(HHID_panel) 
eststo est3

xtreg hdd9_own  pdd9   $xlist  pdd9_mean $year_NIGER if country==1, cluster(HHID_panel) 
eststo est4


xtreg hdd9_own  pdd9   $xlist  pdd9_mean $year_NIGERIA if country==2, cluster(HHID_panel) 
eststo est5


xtreg hdd9_own  pdd9   $xlist  pdd9_mean $year_TANZANIA if country==5, cluster(HHID_panel) 
eststo est6


xtreg hdd9_own  pdd9   $xlist  pdd9_mean  $year_UGANDA if country==4, cluster(HHID_panel) 
eststo est7
esttab using  S13_balance.rtf, se replace star(* 0.1 ** 0.05 *** 0.01) cells (b(star fmt(%9.3f)) se (par(( )) fmt(%9.3f)))  stats(N r2_b  r2_w r2_o p, fmt(%4.0f %4.3f %4.3f %6.3f)) keep(pdd9   $xlist  pdd9_mean _cons)



eststo clear
xtreg hdd9_purchase  pdd9   $xlist  pdd9_mean i.country i.year  , cluster(HHID_panel) 
eststo est1


xtreg hdd9_purchase  pdd9   $xlist  pdd9_mean $year_ETHIOPIA if country==3, cluster(HHID_panel) 
eststo est2

xtreg hdd9_purchase  pdd9   $xlist  pdd9_mean $year_MALAWI if country==6, cluster(HHID_panel) 
eststo est3

xtreg hdd9_purchase  pdd9   $xlist  pdd9_mean $year_NIGER if country==1, cluster(HHID_panel) 
eststo est4


xtreg hdd9_purchase  pdd9   $xlist  pdd9_mean $year_NIGERIA if country==2, cluster(HHID_panel) 
eststo est5


xtreg hdd9_purchase  pdd9   $xlist  pdd9_mean $year_TANZANIA if country==5, cluster(HHID_panel) 
eststo est6


xtreg hdd9_purchase  pdd9   $xlist  pdd9_mean  $year_UGANDA if country==4, cluster(HHID_panel) 
eststo est7

esttab using  S14_balance.rtf, se replace star(* 0.1 ** 0.05 *** 0.01) cells (b(star fmt(%9.3f)) se (par(( )) fmt(%9.3f)))  stats(N r2_b  r2_w r2_o p, fmt(%4.0f %4.3f %4.3f %6.3f)) keep(pdd9   $xlist  pdd9_mean _cons)
restore


********************************************************************************
*                                 S15-S18                                      *
********************************************************************************
preserve
drop if sum_vill<=1|sum_vill==.

drop pdd9_mean no_species_mean hhsize_mean dependent_share_mean head_age_mean female_head_mean head_read_mean motobike_mean phone_mean electricity_mean wagejob_mean enterprise_mean weather_shock_mean plot_area_mean other_crop_mean
egen pdd9_mean=mean(pdd9), by(HHID_panel)
egen pdd9_mean_vill=mean(pdd9_vill), by(HHID_panel)
egen pdd9_mean_town=mean(pdd9_town), by(HHID_panel)
egen pdd9_mean_dist=mean(pdd9_dist), by(HHID_panel)

foreach x of varlist hhsize dependent_share head_age female_head head_read  motobike phone  electricity wagejob enterprise weather_shock  plot_area other_crop{
egen `x'_mean=mean(`x'), by(HHID_panel)
}


*                                  hh_level                                    *
eststo clear
xtreg hdd9  pdd9   $xlist  pdd9_mean i.country i.year  , cluster(HHID_panel) 
eststo est1

xtreg hdd9  pdd9   $xlist  pdd9_mean $year_ETHIOPIA if country==3, cluster(HHID_panel) 
eststo est2

xtreg hdd9  pdd9   $xlist  pdd9_mean $year_MALAWI if country==6, cluster(HHID_panel) 
eststo est3


xtreg hdd9  pdd9   $xlist  pdd9_mean $year_NIGER if country==1, cluster(HHID_panel) 
eststo est4


xtreg hdd9  pdd9   $xlist  pdd9_mean $year_NIGERIA if country==2, cluster(HHID_panel) 
eststo est5


xtreg hdd9  pdd9   $xlist  pdd9_mean $year_TANZANIA if country==5, cluster(HHID_panel) 
eststo est6


xtreg hdd9  pdd9   $xlist  pdd9_mean  $year_UGANDA if country==4, cluster(HHID_panel) 
eststo est7


esttab using  S15_balance.rtf, se replace star(* 0.1 ** 0.05 *** 0.01) cells (b(star fmt(%9.3f)) se (par(( )) fmt(%9.3f)))  stats(N r2_b  r2_w r2_o p, fmt(%4.0f %4.3f %4.3f %6.3f)) keep(pdd9   $xlist  pdd9_mean _cons )





*                          vill_village_level                                  *

eststo clear
xtreg hdd9  pdd9_vill sum_vill  $xlist  pdd9_mean_vill i.country i.year   , cluster(HHID_panel) 
eststo est1

xtreg hdd9  pdd9_vill sum_vill  $xlist  pdd9_mean_vill $year_ETHIOPIA if country==3, cluster(HHID_panel) 
eststo est2

xtreg hdd9  pdd9_vill sum_vill  $xlist  pdd9_mean_vill $year_MALAWI  if country==6, cluster(HHID_panel) 
eststo est3

xtreg hdd9  pdd9_vill sum_vill  $xlist  pdd9_mean_vill $year_NIGER if country==1, cluster(HHID_panel) 
eststo est4


xtreg hdd9  pdd9_vill sum_vill  $xlist  pdd9_mean_vill $year_NIGERIA if country==2, cluster(HHID_panel) 
eststo est5


xtreg hdd9  pdd9_vill sum_vill  $xlist  pdd9_mean_vill $year_TANZANIA if country==5, cluster(HHID_panel) 
eststo est6


xtreg hdd9  pdd9_vill sum_vill  $xlist  pdd9_mean_vill $year_UGANDA if country==4, cluster(HHID_panel) 
eststo est7
esttab using  S16_balance.rtf, se replace star(* 0.1 ** 0.05 *** 0.01) cells (b(star fmt(%9.3f)) se (par(( )) fmt(%9.3f)))  stats(N r2_b  r2_w r2_o p, fmt(%4.0f %4.3f %4.3f %6.3f)) keep(pdd9_vill    $xlist  pdd9_mean_vill sum_vill _cons)






*                          town_village_level                                  *
eststo clear
xtreg hdd9  pdd9_town sum_town  $xlist  pdd9_mean_town i.country i.year   , cluster(HHID_panel) 
eststo est1

xtreg hdd9  pdd9_town sum_town  $xlist  pdd9_mean_town $year_ETHIOPIA if country==3, cluster(HHID_panel) 
eststo est2

xtreg hdd9  pdd9_town sum_town  $xlist  pdd9_mean_town $year_MALAWI  if country==6, cluster(HHID_panel) 
eststo est3

xtreg hdd9 pdd9_town sum_town  $xlist  pdd9_mean_town $year_NIGER if country==1, cluster(HHID_panel) 
eststo est4


xtreg hdd9  pdd9_town sum_town  $xlist  pdd9_mean_town $year_NIGERIA if country==2, cluster(HHID_panel) 
eststo est5


xtreg hdd9  pdd9_town sum_town  $xlist  pdd9_mean_town $year_TANZANIA if country==5, cluster(HHID_panel) 
eststo est6


xtreg hdd9  pdd9_town sum_town  $xlist  pdd9_mean_town $year_UGANDA if country==4, cluster(HHID_panel) 
eststo est7
esttab using  S17_balance.rtf, se replace star(* 0.1 ** 0.05 *** 0.01) cells (b(star fmt(%9.3f)) se (par(( )) fmt(%9.3f)))  stats(N r2_b  r2_w r2_o p, fmt(%4.0f %4.3f %4.3f %6.3f)) keep(pdd9_town    $xlist  pdd9_mean_town sum_town _cons)




*                          dist_village_level                                  *

eststo clear
xtreg hdd9  pdd9_dist  sum_dist  $xlist pdd9_mean_dist i.country i.year   , cluster(HHID_panel) 
eststo est1

xtreg hdd9  pdd9_dist  sum_dist  $xlist pdd9_mean_dist $year_ETHIOPIA if country==3, cluster(HHID_panel) 
eststo est2

xtreg hdd9  pdd9_dist  sum_dist  $xlist pdd9_mean_dist $year_MALAWI  if country==6, cluster(HHID_panel) 
eststo est3

xtreg hdd9 pdd9_dist  sum_dist  $xlist pdd9_mean_dist $year_NIGER if country==1, cluster(HHID_panel) 
eststo est4


xtreg hdd9  pdd9_dist  sum_dist  $xlist pdd9_mean_dist $year_NIGERIA if country==2, cluster(HHID_panel) 
eststo est5


xtreg hdd9  pdd9_dist  sum_dist  $xlist pdd9_mean_dist $year_TANZANIA if country==5, cluster(HHID_panel) 
eststo est6


xtreg hdd9  pdd9_dist  sum_dist  $xlist pdd9_mean_dist $year_UGANDA if country==4, cluster(HHID_panel) 
eststo est7
esttab using  S18_balance.rtf, se replace star(* 0.1 ** 0.05 *** 0.01) cells (b(star fmt(%9.3f)) se (par(( )) fmt(%9.3f)))  stats(N r2_b  r2_w r2_o p, fmt(%4.0f %4.3f %4.3f %6.3f)) keep(pdd9_dist    $xlist  pdd9_mean_dist sum_dist _cons)
restore




























********************************************************************************
*                 Balanced sample with Heckman selection correction
********************************************************************************
use  NER_panel_data.dta, clear
gen country=1
append using NIGERIA_panel_data.dta
replace country=2 if country ==.

append using ETHIOPIA_panel_data.dta
replace country=3 if country ==.

append using UGA_panel_data.dta
replace country=4 if country ==.

append using TZA_panel_data.dta
replace country=5 if country ==.

append using MWI_panel_data.dta
replace country=6 if country ==.

xtset HHID_panel year

label define country 1 "Niger" 2 "Nigeria" 3 "Ethiopia" 4 "Uganda" 5 "Tanzania" 6 "Malawi"
label values country country


gen dyear=1
egen total_year=sum(dyear), by(HHID_panel)

gen balance=0
replace balance=1 if total_year==2&country==1
replace balance=1 if total_year==4&country==2
replace balance=1 if total_year==3&country==3
replace balance=1 if total_year==7&country==4
replace balance=1 if total_year==5&country==5
replace balance=1 if total_year==4&country==6
tab country year

egen mean_balance=mean(balance), by(country year)

probit balance pdd9 hhsize dependent_share head_age female_head head_read  motobike phone  electricity wagejob enterprise weather_shock  plot_area other_crop mean_balance i.country i.year
predict xb, xb
gen double imr = normalden(xb)/normal(xb)
keep if balance==1


foreach x of varlist hhsize dependent_share head_age female_head head_read  motobike phone  electricity wagejob enterprise weather_shock  plot_area other_crop hdd9 pdd9 no_species{
egen `x'_mean=mean(`x'), by(HHID_panel)
}



tab year, generate(year_)
global year_NIGER year_4
global year_NIGERIA year_3 year_5 year_8
global year_ETHIOPIA year_6
global year_UGANDA   year_3 year_4 year_6 year_8 year_10
global year_TANZANIA year_1 year_5 year_7
global year_MALAWI year_3 year_6 
global xlist hhsize dependent_share head_age female_head head_read  motobike phone  electricity wagejob enterprise weather_shock  plot_area other_crop  motobike_mean phone_mean electricity_mean wagejob_mean enterprise_mean  imr







********************************************************************************
*                                   S11                                        *
********************************************************************************
eststo clear
xtreg hdd9  no_species   $xlist  no_species_mean i.country i.year  , cluster(HHID_panel) 
eststo est1


xtreg hdd9  no_species   $xlist  no_species_mean $year_ETHIOPIA if country==3, cluster(HHID_panel) 
eststo est2

xtreg hdd9  no_species   $xlist  no_species_mean $year_MALAWI if country==6, cluster(HHID_panel) 
eststo est3


xtreg hdd9  no_species   $xlist  no_species_mean $year_NIGER if country==1, cluster(HHID_panel) 
eststo est4


xtreg hdd9  no_species   $xlist  no_species_mean $year_NIGERIA if country==2, cluster(HHID_panel) 
eststo est5


xtreg hdd9  no_species   $xlist  no_species_mean $year_TANZANIA if country==5, cluster(HHID_panel) 
eststo est6

xtreg hdd9  no_species   $xlist  no_species_mean  $year_UGANDA if country==4, cluster(HHID_panel) 
eststo est7

esttab using  S11_balance_imr.rtf, se replace star(* 0.1 ** 0.05 *** 0.01) cells (b(star fmt(%9.3f)) se (par(( )) fmt(%9.3f)))  stats(N r2_b  r2_w r2_o p, fmt(%4.0f %4.3f %4.3f %6.3f)) keep(no_species   $xlist  no_species_mean _cons)






********************************************************************************
*                                   S12                                        *
********************************************************************************
eststo clear

xtreg hdd9  pdd9   $xlist   pdd9_mean i.country i.year, cluster(HHID_panel) 
eststo est1


xtreg hdd9  pdd9   $xlist  pdd9_mean $year_ETHIOPIA if country==3, cluster(HHID_panel) 
eststo est2

xtreg hdd9  pdd9   $xlist  pdd9_mean $year_MALAWI if country==6, cluster(HHID_panel) 
eststo est3


xtreg hdd9  pdd9   $xlist  pdd9_mean $year_NIGER if country==1, cluster(HHID_panel) 
eststo est4


xtreg hdd9  pdd9   $xlist  pdd9_mean $year_NIGERIA if country==2, cluster(HHID_panel) 
eststo est5


xtreg hdd9  pdd9   $xlist  pdd9_mean $year_TANZANIA if country==5, cluster(HHID_panel) 
eststo est6

xtreg hdd9  pdd9   $xlist  pdd9_mean  $year_UGANDA if country==4, cluster(HHID_panel) 
eststo est7
esttab using  S12_balance_imr.rtf, se replace star(* 0.1 ** 0.05 *** 0.01) cells (b(star fmt(%9.3f)) se (par(( )) fmt(%9.3f)))  stats(N r2_b  r2_w r2_o p, fmt(%4.0f %4.3f %4.3f %6.3f)) keep(pdd9   $xlist  pdd9_mean _cons)











******************************************************************************** 
*                                  S13_S14                                     *
********************************************************************************
preserve
eststo clear
drop if hdd9_own==.|hdd9_purchase==.
drop  pdd9_mean no_species_mean hhsize_mean dependent_share_mean head_age_mean female_head_mean head_read_mean motobike_mean phone_mean electricity_mean wagejob_mean enterprise_mean weather_shock_mean plot_area_mean other_crop_mean
foreach x of varlist pdd9 hhsize dependent_share head_age female_head head_read  motobike phone  electricity wagejob enterprise weather_shock  plot_area other_crop{
egen `x'_mean=mean(`x'), by(HHID_panel)
}

eststo clear
xtreg hdd9_own  pdd9   $xlist  pdd9_mean i.country i.year  , cluster(HHID_panel) 
eststo est1


xtreg hdd9_own  pdd9   $xlist  pdd9_mean $year_ETHIOPIA if country==3, cluster(HHID_panel) 
eststo est2

xtreg hdd9_own  pdd9   $xlist  pdd9_mean $year_MALAWI if country==6, cluster(HHID_panel) 
eststo est3

xtreg hdd9_own  pdd9   $xlist  pdd9_mean $year_NIGER if country==1, cluster(HHID_panel) 
eststo est4


xtreg hdd9_own  pdd9   $xlist  pdd9_mean $year_NIGERIA if country==2, cluster(HHID_panel) 
eststo est5


xtreg hdd9_own  pdd9   $xlist  pdd9_mean $year_TANZANIA if country==5, cluster(HHID_panel) 
eststo est6


xtreg hdd9_own  pdd9   $xlist  pdd9_mean  $year_UGANDA if country==4, cluster(HHID_panel) 
eststo est7
esttab using  S13_balance_imr.rtf, se replace star(* 0.1 ** 0.05 *** 0.01) cells (b(star fmt(%9.3f)) se (par(( )) fmt(%9.3f)))  stats(N r2_b  r2_w r2_o p, fmt(%4.0f %4.3f %4.3f %6.3f)) keep(pdd9   $xlist  pdd9_mean _cons)



eststo clear
xtreg hdd9_purchase  pdd9   $xlist  pdd9_mean i.country i.year  , cluster(HHID_panel) 
eststo est1


xtreg hdd9_purchase  pdd9   $xlist  pdd9_mean $year_ETHIOPIA if country==3, cluster(HHID_panel) 
eststo est2

xtreg hdd9_purchase  pdd9   $xlist  pdd9_mean $year_MALAWI if country==6, cluster(HHID_panel) 
eststo est3

xtreg hdd9_purchase  pdd9   $xlist  pdd9_mean $year_NIGER if country==1, cluster(HHID_panel) 
eststo est4


xtreg hdd9_purchase  pdd9   $xlist  pdd9_mean $year_NIGERIA if country==2, cluster(HHID_panel) 
eststo est5


xtreg hdd9_purchase  pdd9   $xlist  pdd9_mean $year_TANZANIA if country==5, cluster(HHID_panel) 
eststo est6


xtreg hdd9_purchase  pdd9   $xlist  pdd9_mean  $year_UGANDA if country==4, cluster(HHID_panel) 
eststo est7

esttab using  S14_balance_imr.rtf, se replace star(* 0.1 ** 0.05 *** 0.01) cells (b(star fmt(%9.3f)) se (par(( )) fmt(%9.3f)))  stats(N r2_b  r2_w r2_o p, fmt(%4.0f %4.3f %4.3f %6.3f)) keep(pdd9   $xlist  pdd9_mean _cons)
restore


********************************************************************************
*                                 S15-S18                                      *
********************************************************************************
preserve
drop if sum_vill<=1|sum_vill==.

drop pdd9_mean no_species_mean hhsize_mean dependent_share_mean head_age_mean female_head_mean head_read_mean motobike_mean phone_mean electricity_mean wagejob_mean enterprise_mean weather_shock_mean plot_area_mean other_crop_mean
egen pdd9_mean=mean(pdd9), by(HHID_panel)
egen pdd9_mean_vill=mean(pdd9_vill), by(HHID_panel)
egen pdd9_mean_town=mean(pdd9_town), by(HHID_panel)
egen pdd9_mean_dist=mean(pdd9_dist), by(HHID_panel)

foreach x of varlist hhsize dependent_share head_age female_head head_read  motobike phone  electricity wagejob enterprise weather_shock  plot_area other_crop{
egen `x'_mean=mean(`x'), by(HHID_panel)
}


*                                  hh_level                                    *
eststo clear
xtreg hdd9  pdd9   $xlist  pdd9_mean i.country i.year  , cluster(HHID_panel) 
eststo est1

xtreg hdd9  pdd9   $xlist  pdd9_mean $year_ETHIOPIA if country==3, cluster(HHID_panel) 
eststo est2

xtreg hdd9  pdd9   $xlist  pdd9_mean $year_MALAWI if country==6, cluster(HHID_panel) 
eststo est3


xtreg hdd9  pdd9   $xlist  pdd9_mean $year_NIGER if country==1, cluster(HHID_panel) 
eststo est4


xtreg hdd9  pdd9   $xlist  pdd9_mean $year_NIGERIA if country==2, cluster(HHID_panel) 
eststo est5


xtreg hdd9  pdd9   $xlist  pdd9_mean $year_TANZANIA if country==5, cluster(HHID_panel) 
eststo est6


xtreg hdd9  pdd9   $xlist  pdd9_mean  $year_UGANDA if country==4, cluster(HHID_panel) 
eststo est7


esttab using  S15_balance_imr.rtf, se replace star(* 0.1 ** 0.05 *** 0.01) cells (b(star fmt(%9.3f)) se (par(( )) fmt(%9.3f)))  stats(N r2_b  r2_w r2_o p, fmt(%4.0f %4.3f %4.3f %6.3f)) keep(pdd9   $xlist  pdd9_mean _cons )





*                          vill_village_level                                  *

eststo clear
xtreg hdd9  pdd9_vill sum_vill  $xlist  pdd9_mean_vill i.country i.year   , cluster(HHID_panel) 
eststo est1

xtreg hdd9  pdd9_vill sum_vill  $xlist  pdd9_mean_vill $year_ETHIOPIA if country==3, cluster(HHID_panel) 
eststo est2

xtreg hdd9  pdd9_vill sum_vill  $xlist  pdd9_mean_vill $year_MALAWI  if country==6, cluster(HHID_panel) 
eststo est3

xtreg hdd9  pdd9_vill sum_vill  $xlist  pdd9_mean_vill $year_NIGER if country==1, cluster(HHID_panel) 
eststo est4


xtreg hdd9  pdd9_vill sum_vill  $xlist  pdd9_mean_vill $year_NIGERIA if country==2, cluster(HHID_panel) 
eststo est5


xtreg hdd9  pdd9_vill sum_vill  $xlist  pdd9_mean_vill $year_TANZANIA if country==5, cluster(HHID_panel) 
eststo est6


xtreg hdd9  pdd9_vill sum_vill  $xlist  pdd9_mean_vill $year_UGANDA if country==4, cluster(HHID_panel) 
eststo est7
esttab using  S16_balance_imr.rtf, se replace star(* 0.1 ** 0.05 *** 0.01) cells (b(star fmt(%9.3f)) se (par(( )) fmt(%9.3f)))  stats(N r2_b  r2_w r2_o p, fmt(%4.0f %4.3f %4.3f %6.3f)) keep(pdd9_vill    $xlist  pdd9_mean_vill sum_vill _cons)






*                          town_village_level                                  *
eststo clear
xtreg hdd9  pdd9_town sum_town  $xlist  pdd9_mean_town i.country i.year   , cluster(HHID_panel) 
eststo est1

xtreg hdd9  pdd9_town sum_town  $xlist  pdd9_mean_town $year_ETHIOPIA if country==3, cluster(HHID_panel) 
eststo est2

xtreg hdd9  pdd9_town sum_town  $xlist  pdd9_mean_town $year_MALAWI  if country==6, cluster(HHID_panel) 
eststo est3

xtreg hdd9 pdd9_town sum_town  $xlist  pdd9_mean_town $year_NIGER if country==1, cluster(HHID_panel) 
eststo est4


xtreg hdd9  pdd9_town sum_town  $xlist  pdd9_mean_town $year_NIGERIA if country==2, cluster(HHID_panel) 
eststo est5


xtreg hdd9  pdd9_town sum_town  $xlist  pdd9_mean_town $year_TANZANIA if country==5, cluster(HHID_panel) 
eststo est6


xtreg hdd9  pdd9_town sum_town  $xlist  pdd9_mean_town $year_UGANDA if country==4, cluster(HHID_panel) 
eststo est7
esttab using  S17_balance_imr.rtf, se replace star(* 0.1 ** 0.05 *** 0.01) cells (b(star fmt(%9.3f)) se (par(( )) fmt(%9.3f)))  stats(N r2_b  r2_w r2_o p, fmt(%4.0f %4.3f %4.3f %6.3f)) keep(pdd9_town    $xlist  pdd9_mean_town sum_town _cons)




*                          dist_village_level                                  *

eststo clear
xtreg hdd9  pdd9_dist  sum_dist  $xlist pdd9_mean_dist i.country i.year   , cluster(HHID_panel) 
eststo est1

xtreg hdd9  pdd9_dist  sum_dist  $xlist pdd9_mean_dist $year_ETHIOPIA if country==3, cluster(HHID_panel) 
eststo est2

xtreg hdd9  pdd9_dist  sum_dist  $xlist pdd9_mean_dist $year_MALAWI  if country==6, cluster(HHID_panel) 
eststo est3

xtreg hdd9 pdd9_dist  sum_dist  $xlist pdd9_mean_dist $year_NIGER if country==1, cluster(HHID_panel) 
eststo est4


xtreg hdd9  pdd9_dist  sum_dist  $xlist pdd9_mean_dist $year_NIGERIA if country==2, cluster(HHID_panel) 
eststo est5


xtreg hdd9  pdd9_dist  sum_dist  $xlist pdd9_mean_dist $year_TANZANIA if country==5, cluster(HHID_panel) 
eststo est6


xtreg hdd9  pdd9_dist  sum_dist  $xlist pdd9_mean_dist $year_UGANDA if country==4, cluster(HHID_panel) 
eststo est7
esttab using  S18_balance_imr.rtf, se replace star(* 0.1 ** 0.05 *** 0.01) cells (b(star fmt(%9.3f)) se (par(( )) fmt(%9.3f)))  stats(N r2_b  r2_w r2_o p, fmt(%4.0f %4.3f %4.3f %6.3f)) keep(pdd9_dist    $xlist  pdd9_mean_dist sum_dist _cons)
restore
log close







